/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kelaite.procurement.utils;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author adminitrator
 */
public class MailSender {
    
    /**
     * 发送邮件
     * @param address  邮件地址
     * @param subject  主题
     * @param content  内容，支持html
     * @return 
     */
    public static boolean sendMail(String address, String subject, String content) {
        int ret = 0;
        String cmd = "mail -s " + subject + " " + address;
        String[] cmdA = { "/bin/sh", "-c", cmd};  
        try {  
            Process process = Runtime.getRuntime().exec(cmdA);
            process.waitFor();
            ret = process.exitValue();
        } catch (IOException ex) {
            Logger.getLogger(MailSender.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InterruptedException ex) {
            Logger.getLogger(MailSender.class.getName()).log(Level.SEVERE, null, ex);
        }
        return ret == 0;
    }
}
